package com.system.service.impl;

import com.system.mapper.SysRoleMapper;
import com.system.model.SysRole;
import com.system.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysRoleServiceImpl implements SysRoleService {
    @Autowired
    private SysRoleMapper sysRoleMapper;

    //    查询所有role列表
    @Override
    public List<SysRole> queryAllSysRole() {
        List<SysRole> sysRoleList = sysRoleMapper.queryAllSysRole();
        return sysRoleList;
    }

    /**
     * 添加角色信息
     * @param sysRole
     * @return
     */
    @Override
    public int sysRoleAdd(SysRole sysRole) {
        int i = sysRoleMapper.insertSelective(sysRole);
        return i;
    }

    /**
     * 根据id查询角色信息
     * @param sysRoleIdStr
     * @return
     */
    @Override
    public SysRole sysRoleUpdateUI(String sysRoleIdStr) {
        SysRole sysRole_db = sysRoleMapper.selectByPrimaryKey(Integer.parseInt(sysRoleIdStr));
        return sysRole_db;
    }

    /**
     * 修改角色信息
     * @param sysRole
     * @return
     */
    @Override
    public int sysRoleUpdate(SysRole sysRole) {
        int i = sysRoleMapper.updateByPrimaryKeySelective(sysRole);
        return i;
    }

    /**
     * 删除角色信息
     * @param sysRoleIdStr
     * @return
     */
    @Override
    public int sysRoleDelete(String sysRoleIdStr) {
        int i = sysRoleMapper.deleteByPrimaryKey(Integer.parseInt(sysRoleIdStr));
        return i;
    }

}

